﻿using System;
using System.Data;
using System.Linq;
namespace WPFExcelReport
{
    public partial class ITXEXRPT
    {

        private void JLTAB05NWBCARD()
        {
           string SRC = "";
            DataRow dwABP = null; 
            exAgent.SetCurrentSheet("JLTAB05CARD");
            DataTable dtABF = dsSource.Tables["ABFOLGE"];
            DataTable dwTXT = dsSource.Tables["TXTKON"];
            int i = 12;
            if (dwTXT.Rows.Count > 0)
            {
                foreach (DataRow dwTX in dwTXT.Rows)
                {
                    exAgent.SetCellValue(i, 5, Helpers.Helper.GetGB2312Value(dwTX["TXTKTEXT"].ToString().Trim()));
                    i++;
                }
            }
            dwABP = dsSource.Tables["ABPOS"].Rows[0];
            date = date.Substring(0, 4) + "/" + date.Substring(4, 2) + "/" + date.Substring(6, 2);
            exAgent.SetCellValue(6, 30, date);
            SRC = dwABP["ART"].ToString().Trim();
            exAgent.SetCellValue(7, 5, Helpers.Helper.GetGB2312Value(SRC).Trim());
            SRC = dwABP["TRA"].ToString().Trim();
            exAgent.SetCellValue(7, 19, SRC);
            SRC = dwABP["WID"].ToString().Trim();
            exAgent.SetCellValue(8, 5, SRC);
            SRC = dwABP["FIN"].ToString().Trim();
            exAgent.SetCellValue(8, 19, Helpers.Helper.GetGB2312Value(SRC).Trim());
            SRC = dwABP["DES"].ToString().Trim();
            exAgent.SetCellValue(9, 5, Helpers.Helper.GetGB2312Value(SRC).Trim());
            SRC = dwABP["WBBTP"].ToString().Trim();
            exAgent.SetCellValue(1, 16, "*"+SRC+"*");
            SRC = dwABP["ABPART"].ToString().Trim();
            exAgent.SetCellValue(6, 5, SRC);
            SRC = dwABP["ABPFARBE"].ToString().Trim();
            exAgent.SetCellValue(6, 19, SRC);

           
            int x =19 ;
            foreach (DataRow dwABF in dtABF.Rows)
            {                
                SRC = dwABF["ABFAFOLGE"].ToString().Trim().PadRight(6);
                exAgent.SetCellValue(x, 1, SRC);
                SRC = dwABF["STEP"].ToString();
                exAgent.SetCellValue(x, 10, Helpers.Helper.GetGB2312Value(SRC).Trim());
                exAgent.SetCellValue(x+1,1,"1");
                x = x + 2;
            }
            exAgent.RenameSheet("布车卡"); 
        } 
    }
}